<template>
	<view style="padding-top: 20upx;">
		<view class="webkit list">
			<view class="title">原支付密码</view>
			<input type="text" password @blur="oldIpt" class="flex" placeholder="请输入原支付密码"/>
		</view>
		<view class="webkit list">
			<view class="title">新支付密码</view>
			<input type="text" password @blur="newIpt" class="flex" placeholder="请输入新支付密码" />
		</view>
		<view class="webkit list">
			<view class="title">确认新密码</view>
			<input type="text" password @blur="nicknameIpt" class="flex" placeholder="请确认新支付密码" />
		</view>
		<view style="text-align: center;color: #999;">如果忘记原支付密码，请联系管理员修改</view>
		<view style="padding: 0 24upx;">
			<button type="primary" style="background-image: linear-gradient(to bottom, rgb(243, 109, 31), rgb(252, 9, 9));margin-top: 20upx;" @click="submit">确认修改</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				paypwd:'',
				paypwd1:'',
				oldpaypwd:'',
				openid:'',
				haspwd:false
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../../login/login'
					});
				}
			});
		},
		methods:{
			setAjax(){
				uni.request({
					url: 'http://m.wpweipin.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.paypwd&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						uni.hideLoading()
						this.paypwd = res.data.member.paypwd
						if(res.data.member.paypwd !='' && res.data.member.paypwd != null){
							this.haspwd = true
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			oldIpt(e){
				this.oldpaypwd =  e.detail.value
			},
			newIpt(e){
				this.paypwd =  e.detail.value
			},
			nicknameIpt(e){
				this.paypwd1 =  e.detail.value
			},
			submit(){
				uni.showLoading()
				var data = {
					'openid':this.openid,
					'paypass':this.paypwd,
					'confirm':this.paypwd1,
					'oldpaypass':this.oldpaypwd,
				};
				uni.request({
					url: 'http://m.wpweipin.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.bind.paypasschange&app=1',
					method: 'POST',
					data:data,
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						uni.hideLoading()
						if(res.data.status ==1){
							uni.showToast({
								title: res.data.result.message,
								icon:"none"
							});
							setTimeout(() =>{
								uni.switchTab({
									url:'../../../pages/member/member'
								})
							},1500)
						}else{
							uni.showToast({
								title: res.data.result.message,
								icon:"none"
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
			
		}
	}
</script>

<style>.list{padding:16upx 24upx;background:#fff;margin-bottom:20upx;}.list .title{width:150upx;line-height:50upx;color:#666;}.list .flex{line-height:50upx;color:#666;padding-left:24upx;}.list .right{color:#999;}</style>